<template>
    <FIDrawer v-model="visible"  title="测试序列号" @close="closeClick" @confirm="saveFunc">
        <FIForm :rules="registerRules" ref="ruleForm">
          <!-- {{props.formData.seqTypeId}} -->
            <FIFormItem prop="formEname" label="序列号编码">
                <FIInput v-model="register.seqTypeId" clearable disabled />
                <el-icon><QuestionFilled /></el-icon>
            </FIFormItem>
            <FIFormItem prop="formEname" label="参数1">
                <FIInput v-model="register.param1" clearable />
            </FIFormItem>
            <FIFormItem prop="formEname" label="参数2">
                <FIInput v-model="register.param2" clearable />
            </FIFormItem>
            <!-- <FIFormItem prop="formEname" label="确认密码">
                <FIInput v-model="register.formEname" clearable />
            </FIFormItem> -->
            
            
            <FIFormItem prop="formEname" label="参数3">
                <FIInput v-model="register.param3" clearable />
            </FIFormItem>
            <FIFormItem prop="formEname" label="参数4">
                <FIInput v-model="register.param4" clearable />
            </FIFormItem>
            <FIFormItem prop="formEname" label="参数5">
                <FIInput v-model="register.param5" clearable />
            </FIFormItem>
            <FIFormItem prop="formEname" label="序列号">
                <FIInput v-model="register.seqNo" clearable disabled />
            </FIFormItem>
        </FIForm>
    </FIDrawer>
</template>
  <script lang="ts" setup>
  import { reactive, onMounted, ref, computed, watch,toRaw } from 'vue'
  import FIFormItem from '@/components/FIFormItem.vue'
  import FIInput from '@/components/FIInput.vue'
  import FIForm from '@/components/FIForm.vue'
  import FIDrawer from '@/components/FIDrawer.vue'
  import { apiTestsequenceMaint } from '@/api/configEnvMaint/index'
  import { useMessage} from '@/hooks/message'
  
  const emits = defineEmits(['close','update:modelValue'])
  const props = defineProps({
  // 圆角大小
  modelValue: {
    type: Boolean,
    default: false,
  },
  formData:{
    type: Object,
    default: ()=>{
        return  {}
    },
    
}
})
  const register = reactive({
    param1:'',
    param2:'',
    param3:'',
    param4:'',
    param5:'',
    seqTypeId:props.formData.seqTypeId,
    seqNo:''
    // userName: '',
    // password: '',
    // loginName: '',
    // mobile: '',
    // gender: '',
    // email: '',
    // businessPhone:'',
    // jobNo:'',
    // deptId:'',
  })
  let visible: any = computed({
    get() {
        return props.modelValue
    },
    set(val) {
        emits('update:modelValue', val)
    },
    })
  const registerRules = reactive({
    loginName: [{ required: true, message: '此为必填项', trigger: 'blur' }],
  })
  
  const closeClick = () =>{
    emits('update:modelValue', false)
  }
  const selectData = (val,name) =>{
    // orgSelect.label = name
    register.deptId = val.value
  }
  const saveFunc = () =>{
    let data={
      args:register.param1 + "," + register.param2,
      seqTypeId:register.seqTypeId,
      seqNo:register.seqNo,
      size:1
    }
    apiTestsequenceMaint(toRaw(data))
    .then((res) => {
      if(res.data.success){
        useMessage().success(res.data.message)
        console.log(res.data)
        register.seqNo = res.data.data[0]
      }
    })
    .catch((error: any) => {
      
    })
  }
  
  // watch(
  //     () => props.formData,
  //     (newValue) => {
  //       console.log(newValue)
  //       if(newValue.seqTypeId){
  //         register.seqTypeId = newValue.seqTypeId
  //           // getPostList(newValue.seqTypeId)
  //       }
  //     }
  // );
  </script>
<style lang="less" scoped>
</style>
  